<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>示例7</title>
    <script>
        class Person {
            // 构造函数使用 constructor 关键字作为名称 
            constructor(name, age) {
                console.log("-----------调用 Person 构造-------------")
                this.name = name;
                this.age = age;
            }
            // 定义成员方法 
            show() {-
                console.log("我是：" + this.name + "，我的年龄是：" + this.age);
            }
        }
        // 让 Student 继承 Person 
        class Student extends Person {
            constructor(name, age, hobby) {
                console.log("-----------调用 Student 构造-------------")
                // 报错：ReferenceError: Must call super constructor ... 
                // this.hobby = hobby; // 报错代码 
                super(name, age);
                this.hobby = hobby;
            }
            show() {
                super.show();
                console.log("我的爱好是：" + this.hobby);
            }
        }
        let stu = new Student("张三", 18, "打球");
        stu.show();
    </script>


</head>

<body></body>

</html>